﻿// Copyright (c)  MOKEYISH. All rights reserved.
// Licensed under the MIT License, See License.txt in the project root for license information.

using System;
using System.Data;
using System.Linq.Expressions;
using JetBrains.Annotations;
using NSQL.Expressions;
using NSQL.Query.Compiler;

namespace NSQL.Query
{
    public static class ExpressionCompilerExtensions
    {

        public static Func<DataRow, bool> Complile(this ILogicalExpression logicalExpression, [NotNull]DataTable dataTable)
        {
            return logicalExpression.ComplileToExpression(dataTable).Compile();
        }
        
        public static Expression<Func<DataRow, bool>> ComplileToExpression(this ILogicalExpression logicalExpression, [NotNull]DataTable dataTable)
        {
            return new ExpressionCompiler(dataTable).Complile(logicalExpression);
        }
    }
}